from pydantic import Field, BaseModel
from app.core.settings import Settings


class Mysql(Settings):
    driver = 'mysql'
    url: str = Field(env='DATABASE_URL', default='')
    host: str = '127.0.0.1'
    port: int = 3306
    database: str = ''
    username: str = ''
    password: str = ''
    prefix: str = ''
    charset: str = 'utf8mb4'
    collation: str = 'utf8mb4_unicode_ci'
    unix_socket: str = Field(env='DB_SOCKET', default='')
    prefix_indexes: bool = True
    strict: bool = True
    engine: str = None

    class Config:
        env_prefix = 'db_'


class Connections(BaseModel):
    mysql = Mysql()


class Database(Settings):
    default = Field(env='DB_CONNECTION', default='mysql')
    connections: Connections = Connections()


database = Database()
